<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Sedodream.Web.Common.Contact.Contact>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Edit
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Edit (Classic)</h2>

    <%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try again.") %>
    <p>
        <span class="success-message"><%= ViewData["SuccessMessage"]%></span>
    </p>
    <% using (Html.BeginForm()) {%>

        <fieldset>
            <legend>Fields</legend>
            <ol>
                <li>
                    <label for="Id">Id:</label>
                    <span class="readonly-text"><%= Html.Encode(Model.Id.ToString()) %></span>
                </li>
                <li>
                    <label for="FirstName">FirstName:</label>
                    <%= Html.TextBox("FirstName", Model.FirstName) %>
                    <%= Html.ValidationMessage("FirstName", "*") %>
                </li>
                <li>
                    <label for="LastName">LastName:</label>
                    <%= Html.TextBox("LastName", Model.LastName) %>
                    <%= Html.ValidationMessage("LastName", "*") %>
                </li>
                <li>
                    <label for="Email">Email:</label>
                    <%= Html.TextBox("Email", Model.Email) %>
                    <%= Html.ValidationMessage("Email", "*") %>
                </li>
                <li>
                    <label for="Phone">Phone:</label>
                    <%= Html.TextBox("Phone", Model.Phone) %>
                    <%= Html.ValidationMessage("Phone", "*") %>
                </li>
                <li>
                    <!-- TODO: Move this into the controller -->
                    <%
                        IList<SelectListItem>genderList = new List<SelectListItem>();
                        genderList.Add(new SelectListItem
                        {
                            Text=null,
                            Value=null,
                            Selected=!Model.Gender.HasValue
                        });
                        genderList.Add(new SelectListItem
                        {
                            Text=Sedodream.Web.Common.Contact.Gender.Male.ToString(),
                            Value=Sedodream.Web.Common.Contact.Gender.Male.ToString(),
                            Selected=Model.Gender == Sedodream.Web.Common.Contact.Gender.Male
                        });
                        genderList.Add(new SelectListItem
                        {
                            Text = Sedodream.Web.Common.Contact.Gender.Female.ToString(),
                            Value = Sedodream.Web.Common.Contact.Gender.Female.ToString(),
                            Selected = Model.Gender == Sedodream.Web.Common.Contact.Gender.Female
                        });
                    %>
                    <label for="Gender">Gender:</label>
                    <%= Html.DropDownList("Gender",genderList) %>
                </li>
                <li>
                    <input type="submit" value="Save" />
                </li>
            </ol>
        </fieldset>
    <% } %>

    <div>
        <%=Html.ActionLink("Back to List", "ViewContactsClassic")%>
    </div>

</asp:Content>

